package com.punai.config.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.enums.BusinessType;
import com.punai.config.domain.ConfigInventoryLib;
import com.punai.config.service.IConfigInventoryLibService;
import com.punai.common.utils.poi.ExcelUtil;
import com.punai.common.core.page.TableDataInfo;

/**
 * 清单库Controller
 * 
 * @author zxw_
 * @date 2023-03-22
 */
@RestController
@RequestMapping("/config/inventoryLib")
public class ConfigInventoryLibController extends BaseController
{
    @Autowired
    private IConfigInventoryLibService configInventoryLibService;

    /**
     * 查询清单库列表
     */
    @PreAuthorize("@ss.hasPermi('config:inventoryLib:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConfigInventoryLib configInventoryLib)
    {
        configInventoryLib.setCompanyId(getCompanyId());
        List<ConfigInventoryLib> list = configInventoryLibService.selectConfigInventoryLibList(configInventoryLib);
        return getDataTable(list);
    }

    /**
     * 获取清单库详细信息
     */
    @PreAuthorize("@ss.hasPermi('config:inventoryLib:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(configInventoryLibService.selectConfigInventoryLibById(id));
    }

    /**
     * 新增清单库
     */
    @PreAuthorize("@ss.hasPermi('config:inventoryLib:add')")
    @Log(title = "清单库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConfigInventoryLib configInventoryLib)
    {
        configInventoryLib.setCompanyId(getCompanyId());
        return toAjax(configInventoryLibService.insertConfigInventoryLib(configInventoryLib));
    }

    /**
     * 修改清单库
     */
    @PreAuthorize("@ss.hasPermi('config:inventoryLib:edit')")
    @Log(title = "清单库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConfigInventoryLib configInventoryLib)
    {
        return toAjax(configInventoryLibService.updateConfigInventoryLib(configInventoryLib));
    }

    /**
     * 删除清单库
     */
    @PreAuthorize("@ss.hasPermi('config:inventoryLib:remove')")
    @Log(title = "清单库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(configInventoryLibService.deleteConfigInventoryLibByIds(ids));
    }
}
